<?php

  session_start();
  
  if (isset($_SESSION['playerId'])) {
  	header("Location: select_character.php");
	exit;
  }
  
  $allowed_page = true;  
  
  function __autoload($className) {
    if (!isset($allowed_page)) { $allowed_page = true; }
	require_once("lib/config.php");
	require_once CLASS_PATH."{$className}.class.php";
  }
  
  if (isset($_POST['username']) && isset($_POST['password'])) {	
		if (!isset($_SESSION['engine'])) {
			$_SESSION['engine'] = new Engine();
		}
		$engine = & $_SESSION['engine'];
		$username = addslashes($_POST['username']);
		$password = addslashes($_POST['password']);
		
		try {
			$engine->login($username, $password);
			header("Location: select_character.php");
			exit;
		}
		catch(Exception $e) {
			$message = $e->getMessage();
		}

	
  }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link type="text/css" rel="stylesheet" href="../css/portal.css">
  <title>D5Power WebGame Engine - 用户中心</title>
  
</script>
</head>


<body>

<div id="main_top">
</div>


<div id="container_principal">

  <div id="textura_lateral_esquerda">

	<!-- INÍCIO - Menu lateral -->
	<div class="menu">
	  <div class="menu_esquerda"></div>
	  <div class="menu_direita"></div>
	  <div class="menu_inferior"></div>
	  <div class="menu_superior"></div>

	  <p class="itens_menu">
	    <img border="0" src="../pictures/portal/menu_hover_icon.gif" align="top" width="16" height="17">
	    <b><a href="index.php">主页</a></b><br>

	    <img border="0" src="../pictures/portal/menu_line.gif" width="122" height="5"><br>
  
	    <img border="0" src="../pictures/portal/menu_hover_icon.gif" align="top" width="16" height="17">
	    <b><a href="login.php">登录</a></b><br>

	    <img border="0" src="../pictures/portal/menu_line.gif" width="122" height="5"><br>
  
	    <img border="0" src="../pictures/portal/menu_hover_icon.gif" align="top" width="16" height="17">
	    <b><a href="register.php">注册新帐户</a></b><br>
  
	    <img border="0" src="../pictures/portal/menu_line.gif" width="122" height="5"><br>
	  </p>
	</div>
	<!-- FIM - Menu lateral -->

    
    <div id="barra_lateral_esquerda">
    </div>

  </div>
  <!-- fim do quadro textura lateral -->
     

	<!-- Início do quadro main -->
    <div id="main" style="width:645px">
    	
		<!-- INÍCIO - Quadro de login -->
		<div class="form_header">
			<p><img style="vertical-align: middle;" src="../pictures/portal/header_left.gif"> 用户登录</p>
		</div>
		
		<div class="form_square">
		  <div class="lateral_esquerda"></div>
		  <div class="lateral_direita"></div>
		  <div class="linha_inferior"></div>
		  <div class="linha_superior"></div>
		  <div style="padding: 10px;">

	        <p style="text-align: center;">
			  <b>请输入您的帐与户密码</b>
			</p>

        	<form method="POST" name="login" action="login.php" onSubmit="return true;">
	
              <p align="center">
              	用户名：
                  <input name="username" type="text" class="text" id="user" size="20" maxlength="18">
			  </p>
              
			  <div id="usuario">
              </div>

              <p style="text-align: center;">
              	密　码：
                  <input name="password" type="password" class="text" id="pwd" size="20" maxlength="32">
			  </p>
              
			  <div id="senha">
              </div>
              
			  <p style="text-align: center;">
			  	<input type="submit" value="  登录  " name="button" class="button">
			  </p>

              <p style="text-align: center;">
              	<font size="2" color="#ff1010">
              		<?php
                      if (isset($message)) { print($message); };
                    ?>
				</font>
			  </p>
			  
	        </form>

		  </div>
		  
		</div>
		<!-- FIM - Quadro de login -->  		
		
    </div>
	<!-- fim do quadro main -->

    
    
</div>

</body>
</html>
